home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / shufl1 / sound1.frm < prev    next >
Text File  |  1995-05-08  |  11KB  |  359 lines

  1. VERSION 2.00
  2. Begin Form Sound1 
  3.    Caption         =   "System Sound Shuffler"
  4.    ClientHeight    =   3870
  5.    ClientLeft      =   1185
  6.    ClientTop       =   1545
  7.    ClientWidth     =   7890
  8.    Height          =   4275
  9.    Icon            =   SOUND1.FRX:0000
  10.    Left            =   1125
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3870
  14.    ScaleWidth      =   7890
  15.    Top             =   1200
  16.    Width           =   8010
  17.    Begin CommonDialog CMDialog1 
  18.       Left            =   5400
  19.       Top             =   4320
  20.    End
  21.    Begin CommandButton Command1 
  22.       Caption         =   "E&xit"
  23.       Height          =   375
  24.       Index           =   5
  25.       Left            =   6300
  26.       TabIndex        =   14
  27.       Top             =   3120
  28.       Width           =   1335
  29.    End
  30.    Begin CommandButton Command1 
  31.       Caption         =   "Shu&ffle"
  32.       Height          =   375
  33.       Index           =   4
  34.       Left            =   6300
  35.       TabIndex        =   13
  36.       Top             =   2580
  37.       Width           =   1335
  38.    End
  39.    Begin CommandButton Command1 
  40.       Caption         =   "&Set Current"
  41.       Height          =   375
  42.       Index           =   3
  43.       Left            =   6300
  44.       TabIndex        =   12
  45.       Top             =   2040
  46.       Width           =   1335
  47.    End
  48.    Begin CommandButton Command1 
  49.       Caption         =   "&Play File"
  50.       Height          =   375
  51.       Index           =   2
  52.       Left            =   6300
  53.       TabIndex        =   11
  54.       Top             =   1500
  55.       Width           =   1335
  56.    End
  57.    Begin CommandButton Command1 
  58.       Caption         =   "&Remove File"
  59.       Height          =   375
  60.       Index           =   1
  61.       Left            =   6300
  62.       TabIndex        =   10
  63.       Top             =   960
  64.       Width           =   1335
  65.    End
  66.    Begin CommandButton Command1 
  67.       Caption         =   "&Add File"
  68.       Height          =   375
  69.       Index           =   0
  70.       Left            =   6300
  71.       TabIndex        =   9
  72.       Top             =   420
  73.       Width           =   1335
  74.    End
  75.    Begin PictureBox Picture3 
  76.       BackColor       =   &H00C0C0C0&
  77.       BorderStyle     =   0  'None
  78.       Height          =   3195
  79.       Left            =   240
  80.       ScaleHeight     =   3195
  81.       ScaleWidth      =   5775
  82.       TabIndex        =   0
  83.       Top             =   360
  84.       Width           =   5775
  85.       Begin CheckBox chEnabled 
  86.          BackColor       =   &H00C0C0C0&
  87.          Caption         =   "Shuffling E&nabled"
  88.          Height          =   255
  89.          Left            =   240
  90.          TabIndex        =   6
  91.          Top             =   2760
  92.          Width           =   2775
  93.       End
  94.       Begin ListBox lbFiles 
  95.          Height          =   1395
  96.          Left            =   1020
  97.          TabIndex        =   4
  98.          Top             =   1140
  99.          Width           =   4455
  100.       End
  101.       Begin ComboBox coEvents 
  102.          Height          =   300
  103.          Left            =   1020
  104.          Style           =   2  'Dropdown List
  105.          TabIndex        =   2
  106.          Top             =   240
  107.          Width           =   3315
  108.       End
  109.       Begin Label Label1 
  110.          BackColor       =   &H00C0C0C0&
  111.          Caption         =   "Shuffle &Files:"
  112.          Height          =   435
  113.          Index           =   1
  114.          Left            =   240
  115.          TabIndex        =   3
  116.          Top             =   1140
  117.          Width           =   735
  118.       End
  119.       Begin Label laSound 
  120.          BackColor       =   &H00C0C0C0&
  121.          Height          =   255
  122.          Left            =   1620
  123.          TabIndex        =   8
  124.          Top             =   720
  125.          Width           =   3975
  126.       End
  127.       Begin Label Label2 
  128.          BackColor       =   &H00C0C0C0&
  129.          Caption         =   "Current Sound:"
  130.          Height          =   255
  131.          Left            =   240
  132.          TabIndex        =   7
  133.          Top             =   720
  134.          Width           =   1335
  135.       End
  136.       Begin Label Label1 
  137.          BackColor       =   &H00C0C0C0&
  138.          Caption         =   "&Event:"
  139.          Height          =   255
  140.          Index           =   0
  141.          Left            =   240
  142.          TabIndex        =   1
  143.          Top             =   300
  144.          Width           =   615
  145.       End
  146.    End
  147.    Begin PictureBox Picture1 
  148.       BorderStyle     =   0  'None
  149.       Height          =   255
  150.       Left            =   0
  151.       Picture         =   SOUND1.FRX:0302
  152.       ScaleHeight     =   255
  153.       ScaleWidth      =   375
  154.       TabIndex        =   5
  155.       Top             =   0
  156.       Visible         =   0   'False
  157.       Width           =   375
  158.    End
  159. End
  160. Dim NewFlag As Integer
  161.  
  162. Sub chEnabled_Click ()
  163.     If NewFlag Then Exit Sub
  164.     x% = chEnabled.Value
  165.     Key$ = coEvents.Text
  166.     Res% = WritePrivateProfileString("Enabled", Key$, Str$(x%), "Shuffle.ini")
  167.  
  168. End Sub
  169.  
  170. Sub coEvents_Click ()
  171.     UpdateFiles
  172.     PassedString$ = Space$(gSize)
  173.     Key$ = coEvents.Text
  174.     a% = GetPrivateProfileString("Enabled", Key$, "", PassedString$, gSize, "Shuffle.ini")
  175.     temp$ = Left$(PassedString$, a%)
  176.     NewFlag = True
  177.     If temp$ = "1" Then
  178.     chEnabled.Value = 1
  179.     Else
  180.     chEnabled.Value = 0
  181.     End If
  182.     NewFlag = False
  183. End Sub
  184.  
  185. Sub Command1_Click (Index As Integer)
  186. Select Case Index
  187. Case 0      'Add File
  188.     CMDialog1.DefaultExt = "WAV"
  189.     CMDialog1.DialogTitle = "Select Sound File"
  190.     CMDialog1.FileName = ""
  191.     CMDialog1.Filter = "Sound (*.wav)|*.wav"
  192.     CMDialog1.FilterIndex = 1
  193.     CMDialog1.Flags = OFN_FILEMUSTEXIST Or OFN_NOCHANGEDIR
  194.     If gsInitDir <> "" Then CMDialog1.InitDir = gsInitDir
  195.     CMDialog1.Action = 1
  196.     FName$ = CMDialog1.FileName
  197.     FTitle$ = CMDialog1.FileTitle
  198.     If FName$ <> "" Then
  199.     gsInitDir = Left$(FName$, Len(FName$) - Len(FTitle$) - 1)
  200.     If Len(gsInitDir) < 3 Then gsInitDir = gsInitDir + "\"
  201.     IniApp$ = coEvents.Text
  202.     x% = InStr(FTitle$, ".")
  203.     If x% <> 0 Then
  204.         Key$ = Mid$(FTitle$, 1, x% - 1)
  205.     Else
  206.         Key$ = FTitle$
  207.     End If
  208.     a% = WritePrivateProfileString(IniApp$, Key$, FName$, "Shuffle.ini")
  209.     UpdateFiles
  210.     End If
  211. Case 1      'Remove a file
  212.     If lbFiles.ListIndex = -1 Then
  213.     Msg$ = "Select a sound file to remove"
  214.     MsgType% = MB_ICONASTERISK
  215.     Title$ = "System Sound Shuffler"
  216.     sMsgBox Msg$, MsgType%, Title$
  217.     Exit Sub
  218.     End If
  219.     FName$ = lbFiles.Text
  220.     Msg$ = "Are you sure you want to remove " + FName$ + "?"
  221.     Title$ = "System Sound Shuffler"
  222.     Res% = fMsgBox(Msg$, MB_ICONQUESTION + 3, Title$)
  223.     If Res% = 6 Then
  224.     LastNdx% = 1
  225.     NextNdx% = 1
  226.     Cut% = 0
  227.     While NextNdx% <> 0
  228.         NextNdx% = InStr(LastNdx%, FName$, "\")
  229.         If NextNdx% <> 0 Then
  230.         Cut% = NextNdx%
  231.         End If
  232.         LastNdx% = NextNdx% + 1
  233.     Wend
  234.     If Cut% <> 0 Then
  235.         FName$ = Mid$(FName$, Cut% + 1)
  236.     End If
  237.     x% = InStr(FName$, ".")
  238.     If x% Then FName$ = Left$(FName$, x% - 1)
  239.     IniApp$ = coEvents.Text
  240.     Res% = KillIniKey(IniApp$, FName$, 0&, "Shuffle.ini")
  241.     UpdateFiles
  242.     End If
  243. Case 2      'Play selected file
  244.     If lbFiles.ListIndex = -1 Then
  245.     Msg$ = "Select a sound file to play"
  246.     sMsgBox Msg$, MB_ICONASTERISK, "System Sound Shuffler"
  247.     Exit Sub
  248.     End If
  249.     FName$ = lbFiles.Text
  250.     Sound1.MousePointer = 11
  251.     sndPlaySound FName$, 2
  252.     Sound1.MousePointer = 0
  253. Case 3      'Set Current
  254.     MakeFileCurrent
  255. Case 4      'Randomize
  256.     MousePointer = 11
  257.     Msg1.Show 0
  258.     Junk% = DoEvents()
  259.     Shuffle
  260.     WinKey$ = gEventsArray(coEvents.ListIndex, 1)
  261.     PassedString$ = Space$(gSize)
  262.     a% = GetProfileString("Sounds", WinKey$, "[None]", PassedString$, gSize)
  263.     x% = InStr(PassedString$, ",")
  264.     If x% Then
  265.     CurrentSound$ = Left$(PassedString$, x% - 1)
  266.     Else
  267.     CurrentSound$ = Left$(PassedString$, a%)
  268.     End If
  269.     laSound.Caption = CurrentSound$
  270.     Unload Msg1
  271.     MousePointer = 0
  272. Case 5   'Done
  273.     End
  274. End Select
  275.  
  276. End Sub
  277.  
  278. Sub Form_Load ()
  279.     Screen.MousePointer = 11
  280.     WindowState = 0
  281.